﻿namespace Super.Admin.Utils.EventAggregator
{
    public class SubscriptionToken : IDisposable
    {
        public Type EventType { get; } // 订阅的事件类型
        public Guid Id { get; } = Guid.NewGuid(); // 订阅令牌的唯一标识符
        public SubscriptionToken(Type eventType)
        {
            EventType = eventType;
        }
        /// <summary>
        /// 释放令牌时取消订阅
        /// </summary>
        public void Dispose()
        {
            // 令牌被释放时自动取消订阅
            EventAggregator.Default.Unsubscribe(this);
        }
    }
}
